package com.smarth.zhizulian.popupwindow;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.widget.TextView;

import com.smarth.zhizulian.R;

import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;

/**
 * Created by 18865 on 2018/3/1.
 */

public class CoinDialog extends Dialog {
    private long mCoin;

    public CoinDialog(@NonNull Context context, long coin) {
        super(context, R.style.MyDialog_Just);
        this.mCoin = coin;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_coin);
        TextView tv_coin = findViewById(R.id.tv_coin);
        tv_coin.setText("+" + mCoin + "金币");
    }

    @Override
    public void show() {
        super.show();
        Observable.timer(2, TimeUnit.SECONDS)
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<Long>() {
                    @Override
                    public void accept(Long aLong) throws Exception {
                        CoinDialog.this.dismiss();
                    }
                });
    }
}
